// Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.neuronbit.businessflow.intellij.editor;

import com.intellij.openapi.components.PersistentStateComponent;
import com.intellij.openapi.components.Service;
import com.intellij.openapi.components.State;
import com.intellij.openapi.components.Storage;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.NlsSafe;
import com.intellij.psi.PsiModifier;
import com.intellij.uiDesigner.UIFormXmlConstants;
import com.intellij.util.xmlb.XmlSerializerUtil;
import org.jetbrains.annotations.NotNull;

/**
 * The type Gui designer configuration.
 */
@Service(Service.Level.PROJECT)
@State(name = "businessFlow-uidesigner-configuration", storages = @Storage("businessFlowDesigner.xml"))
public final class GuiDesignerConfiguration implements PersistentStateComponent<GuiDesignerConfiguration> {
    /**
     * Get instance gui designer configuration.
     *
     * @param project the project
     * @return the gui designer configuration
     */
    public static GuiDesignerConfiguration getInstance(final Project project){
    return project.getService(GuiDesignerConfiguration.class);
  }

    /**
     * Defines how the designer generate UI (instrument classes or generate Java code)
     */
    public boolean INSTRUMENT_CLASSES = true;

    /**
     * The Copy forms runtime to output.
     */
    public boolean COPY_FORMS_RUNTIME_TO_OUTPUT = true;

    /**
     * The Default layout manager.
     */
    public @NlsSafe String DEFAULT_LAYOUT_MANAGER = UIFormXmlConstants.LAYOUT_INTELLIJ;

    /**
     * The Default field accessibility.
     */
    public @NlsSafe String DEFAULT_FIELD_ACCESSIBILITY = PsiModifier.PRIVATE;

    /**
     * The Resize headers.
     */
    public boolean RESIZE_HEADERS = true;

    /**
     * The Use dynamic bundles.
     */
    public boolean USE_DYNAMIC_BUNDLES = false;

  @Override
  public GuiDesignerConfiguration getState() {
    return this;
  }

  @Override
  public void loadState(@NotNull GuiDesignerConfiguration object) {
    XmlSerializerUtil.copyBean(object, this);
  }
}
